yjx.controller('msgController', ['$rootScope', '$scope', '$timeout', '$fetch', 'modalService','ipCookie', function ($rootScope, $scope, $timeout, $fetch, modalService,ipCookie) {
    /**swiper */
    var tabList, msgSwiper;
    var width = document.body.offsetWidth;
    var tabSlides = 4;
    $rootScope.identity=$rootScope.identity?$rootScope.identity:ipCookie('identity');
    if($rootScope.identity==1){
        $scope.tabList = [{ id: 1, name: '订单' }, { id: 2, name: '团队' }, { id: 3, name: '提现' },{id:4,name:'其他'}];
        
    }else{
        $scope.tabList = [{ id: 1, name: '订单' },{id:4,name:'其他'}];
        tabSlides = 2
    }
    $scope.curTab = $scope.tabList[0];

    function buildSwiper() {
        tabList = new Swiper('#tabList', {
            slidesPerView: tabSlides,
            slideToClickSlide: true
        });
        msgSwiper = new Swiper('#msgSwiper', {
            direction: 'horizontal',
            slider: width,
            on: {
                slideNextTransitionStart: function () {
                    tabList.slideTo(msgSwiper.activeIndex)
                    $timeout(function () {
                        $scope.curTab = $scope.tabList[msgSwiper.activeIndex];
                    })
                },
                slidePrevTransitionStart: function () {
                    tabList.slideTo(msgSwiper.activeIndex - 1)
                    $timeout(function () {
                        $scope.curTab = $scope.tabList[msgSwiper.activeIndex];
                    })
                }
            }
        })
    }
    $timeout(function () {
        buildSwiper();
    }, 1000)

    $scope.tabSelect = function (item, index) {
        $scope.curTab = item;
        msgSwiper.slideTo(index, 500);
    }
}])